import { Controller, Get, Post, Inject, Query, Body, Put } from "@/common/core";
import { KoaContext } from "@/types";
import { TestService } from "./test.service";
import { Test1Service } from "./test1.service";

@Controller("/test")
export class TextController {
  @Inject() testService: TestService;
  @Inject() test1Service: Test1Service;

  // ctx: Context;
  @Get("/list")
  async list(@Query("id") query: any) {
    const data = await this.testService.test();
    // console.log("Query装饰器解析", query);
    // this.abtestService.test1();
    // console.log('config', this.config);
    return { code: 200, data: data, query: query };
  }
  @Get("/getUser")
  async getUser(@Query() query: any) {
    // const result = await this.test1Service.test1();
    console.log("获取Todo");
    // console.log("获取用户", this.ctx);
    return { code: 200, data: query || "获取Todo" };
  }

  @Post("/saveUser")
  async saveUser(@Body("id") id: any) {
    // const result = await this.abtestService.test1();
    console.log("存储User");
    return { code: 200, data: "result" || "存储User" };
    // return;
  }

  @Put("/saveUser")
  async putUser(@Body() id: any) {
    // const result = await this.abtestService.test1();
    console.log("put");
    return { code: 200, data: "put" || "putUser" };
  }
  @Post("/aa")
  async aa() {
    // const result = await this.abtestService.test1();
    console.log("aa");
    return { code: 200, data: "result" || "aa" };
  }

  @Get("/dd")
  async dd(@Query() query: any) {
    // const result = await this.test1Service.test1();
    console.log("dd");
    // console.log("获取用户", this.ctx);
    return { code: 200, data: query || "dd" };
  }
}
